/*
 * @Descripttion: 
 * @version: 
 * @Author: turingchang
 * @Date: 2020-08-28 14:32:50
 * @LastEditors: turingchang
 * @LastEditTime: 2020-09-09 22:07:54
 */

'use strict';
const BaseController = require('../base/base');

class HomeController extends BaseController {
    async login() {
        const ctx = this.ctx;
        const {username,password} = ctx.request.body;
        const res = await ctx.validate('home.login', {username,password}); 
        if (!res) {
            ctx.outValidateStatus();
            return;
        }
        var login_user ={
            name:username,
            password:password
        }
        console.log(login_user);
        var data =await ctx.service.home.home.login(login_user);
        if(!this.ctx.app.utils.validator.isNull(data.msg)){
            ctx.outError(data.msg, null);
        }else{
            ctx.outSuccess(null, data.data);
        }        
    }    
    async logout(){
        this.ctx.outSuccess('注销成功', null);
    }
    async menu() {
        const ctx = this.ctx;
        var data =await ctx.service.home.home.menu();
        ctx.outSuccess(null, data);
    } 

}

module.exports = HomeController;